package com.weimob.kafka;

import org.apache.kafka.clients.producer.Partitioner;
import org.apache.kafka.common.Cluster;

import java.util.Map;

/**
 * @program: xh-learn-record
 * @description: 自定义分区器
 * @author: sch
 * @create: 2022-12-20 18:41
 **/
public class A005_MyPartitioner implements Partitioner {
    public int partition(String topic, Object key, byte[] keyBytes, Object value, byte[] valueBytes, Cluster cluster) {
        String s = value.toString();
        if(s.equals("hello0")){
            return 0;
        }
        return 2;
    }

    public void close() {

    }

    public void configure(Map<String, ?> configs) {

    }
}
